# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, DateTime, func
import datetime

from utils.work_db import Base

"""
用户信息
"""
# 用户类型
USER_TYPE_GENERAL = 1
USER_TYPE_COMPANY = 2
USER_TYPE_AGENCY = 3


class User(Base):
    __tablename__ = 'user'
    user_id = Column(Integer, primary_key=True, autoincrement=True)
    real_name = Column(String)
    nick_name = Column(String)
    mobile = Column(String)
    tel = Column(String, default='')
    # tel2 = Column(String)
    password = Column(String)
    salt = Column(String)
    email = Column(String)
    ages = Column(String)
    header_img = Column(String)
    status = Column(Integer, default=1)
    gender = Column(Integer, default=3)
    qq = Column(String)
    openid = Column(String)
    wx_nick_name = Column(String)
    wx_token = Column(String)
    token_expire = Column(String)
    refresh_token = Column(String)
    province_code = Column(String)
    province_name = Column(String)
    city_code = Column(String)
    reg_ip = Column(String)
    city_name = Column(String)
    last_login_time = Column(String)
    sec_pub_tel = Column(Integer, default=2)
    sec_pub_recieve = Column(Integer, default=2)
    message_push = Column(Integer, default=2)
    create_time = Column(DateTime, default=func.now())
    update_time = Column(DateTime, default=func.now())
    user_type = Column(Integer, default=1)
    company_id = Column(Integer)

    def json(self):
        return {
            'user_id': self.user_id,
            'real_name': self.real_name,
            'nick_name': self.wx_nick_name,
            'tel': self.tel,
            'email': self.email,
            'age': self.ages,
            'header_img': self.header_img,
            'status': self.status,
            'openid': self.openid,
            'sec_pub_tel': self.sec_pub_tel,
            'sec_pub_recieve': self.sec_pub_recieve,
            'message_push': self.message_push,
            'qq': self.qq,
            'gender': self.gender
        }
